package com.aaa.mks.controller;

import com.aaa.common.constants.ReturnStatus;
import com.aaa.common.util.Result;
import com.aaa.mks.entity.AdvertisePosition;
import com.aaa.mks.service.AdvertisePositionService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 广告位位置(AdvertisePosition)表控制层
 *
 * @author makejava
 * @since 2020-12-05 11:17:25
 */
@RestController
@RequestMapping("advertisePosition")
public class AdvertisePositionController {
    /**
     * 服务对象
     */
    @Resource
    private AdvertisePositionService advertisePositionService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    @ApiOperation("通过主键查询单条数据")
    public AdvertisePosition selectOne(Integer id) {
        return this.advertisePositionService.queryById(id);
    }

    /**
     * 查询所有
     *
     * @param advertisePosition 实体
     * @return Result
     */
    @PostMapping("queryAll")
    @ApiOperation("查询所有")
    public Result queryAll(@RequestBody(required = false) AdvertisePosition advertisePosition) {
        return this.advertisePositionService.queryAll(advertisePosition);
    }

    @PostMapping("queryAllByParam")
    @ApiOperation("查询所有分页加条件查询")
    public Result queryAllByParam(@RequestParam("pageNo") Integer pageNo, @RequestParam("pageSize") Integer pageSize, @RequestBody AdvertisePosition advertisePosition) {
        return this.advertisePositionService.queryAllByParam(pageNo,pageSize,advertisePosition);
    }


        /**
         * 根据ID删除
         *
         * @param id id
         * @return Result
         */
    @DeleteMapping("deleteById")
    @ApiOperation("根据ID删除")
    public Result deleteById(Integer id) {
        return new Result(ReturnStatus.SUCCESS.getReturnCode(),
                ReturnStatus.SUCCESS.getReturnMsg(), this.advertisePositionService.deleteById(id));
    }

    /**
     * 更新
     *
     * @param @param advertisePosition 实例对象
     * @return Result
     */
    @PostMapping("update")
    @ApiOperation("更新")
    public Result update(@ApiParam("更新json数据") @RequestBody AdvertisePosition advertisePosition) {
        return new Result(ReturnStatus.SUCCESS.getReturnCode(),
                ReturnStatus.SUCCESS.getReturnMsg(), this.advertisePositionService.update(advertisePosition));
    }

    /**
     * 添加
     *
     * @param @param advertisePosition 实例对象
     * @return Result
     */
    @PostMapping("insert")
    @ApiOperation("添加")
    public Result insert(@ApiParam("添加json数据") @RequestBody AdvertisePosition advertisePosition) {
        return new Result(ReturnStatus.SUCCESS.getReturnCode(),
                ReturnStatus.SUCCESS.getReturnMsg(), this.advertisePositionService.insert(advertisePosition));
    }
}